unit BaixaOS;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ConModelo;

type
  TfrmBaixaOS = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label1: TLabel;
    edtUsuario: TEdit;
    btnUsuario: TBitBtn;
    stUsuario: TStaticText;
    Label15: TLabel;
    edtDataSaida: TEdit;
    edtHoraSaida: TEdit;
    procedure edtDataSaidaExit(Sender: TObject);
    procedure edtHoraSaidaExit(Sender: TObject);
    procedure btnUsuarioClick(Sender: TObject);
    procedure edtUsuarioExit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmBaixaOS: TfrmBaixaOS;

implementation

uses DmGeral;

{$R *.dfm}

procedure TfrmBaixaOS.edtDataSaidaExit(Sender: TObject);
var
  Data: string;
begin
  inherited;
  Data := edtDataSaida.Text;
  if DtmGeral.TClasseGeral.ValidarData(Data) then
    edtDataSaida.Text := Data
  else
  begin
    edtDataSaida.SetFocus;
    Exit;
  end;
end;

procedure TfrmBaixaOS.edtHoraSaidaExit(Sender: TObject);
var
  Hora: string;
begin
  inherited;
  Hora := edtHoraSaida.Text;
  if DtmGeral.TClasseGeral.ValidarHorario(Hora) then
    edtHoraSaida.Text := Hora
  else
  begin
    edtHoraSaida.SetFocus;
    Exit;
  end;
end;

procedure TfrmBaixaOS.btnUsuarioClick(Sender: TObject);
begin
  if TfrmConModelo.ConModUsuarios then begin
    if ConsultaZeos then begin
      edtUsuario.Text := DtmGeral.CDS_Consulta.FieldbyName('Codigo').AsString;
      DtMGeral.CDS_Consulta.Close;
    end
    else begin
      edtUsuario.Text := DtmGeral.SQLC_Consulta.FieldbyName('Codigo').AsString;
      DtMGeral.SQLC_Consulta.Close;
    end;
    edtUsuario.SetFocus;
  end;
end;

procedure TfrmBaixaOS.edtUsuarioExit(Sender: TObject);
begin
  {Validar o campo Parametros: Componente, (N)ao permitir duplicidade (P)ermitir, SQL a ser executada}
  if Length(Trim(edtUsuario.Text))=0 then begin
    if btnUsuario.Enabled then btnUsuario.SetFocus;
  end
  else
   if ValidaCampo(EdtUsuario, 'P','select USU_CODIGO, USU_NOME from USUARIOS where USU_CODIGO='+
                   QuotedStr(EdtUsuario.Text) + ';') then
      stUsuario.Caption := DtMGeral.sqlq_geral.FieldByName('USU_NOME').AsString;
end;

end.
